#include "kernel.h"
#include "dt.h"

typedef struct __attribute__ ((__packed__)){
	uint16_t	limit;
	uint32_t	address;
}volatile tdtp;

tdtr* dt_clear(unsigned int address, unsigned int count){
	tdtp *tp = (tdtp*)address;
	unsigned int *ptr = (unsigned int*)address;
	unsigned int x;
	for(x = 0; x < count; ++x){
		ptr[x*2+0] = 0;
		ptr[x*2+1] = 1;
	}
	tp->limit = (count * 8) - 1;
	tp->address = address;
	return (tdtr*)address;
}

void dt_nongate(tdtr *dr, unsigned int index, unsigned int base, unsigned int limit, unsigned int attr){
	dr[index].limit0 = limit;
	dr[index].base0 = base;
	dr[index].base1 = base >> 16;
	dr[index].attr0 = attr >> 8;
	dr[index].attr1_limit1 = (attr&0xF0) | ((limit >> 16)&0x0F);
	dr[index].base2 = base >> 24;
	return;
}


